package org.hive.testserver.domain.model.schedule;

import org.hive.testserver.domain.model.Slave;
import org.hive.testserver.domain.model.Test;
import org.hive.testserver.domain.model.TestState;
import org.hive.testserver.domain.model.WorkSheet;

/**
 * Terminating allocator that will accept only untested tests as being suitable for scheduling.
 */
public class UntestedAllocator extends BaseAllocatorLink {

	private static final long serialVersionUID = 1L;

	public UntestedAllocator() {
		super(new NullAllocator());
	}

	@Override
	protected boolean shouldAccept(Test test, Slave slave, WorkSheet workSheet) {
		return test.currentState() == TestState.UNTESTED;
	}
	
	public boolean shouldConsiderTestFinished(Test test) {
		return test.currentState().isTerminating();
	}

	@Override
	protected ScheduleReason scheduledReason() {
		return ScheduleReason.UNTESTED;
	}

}